<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="_documento.xhtml">
	<ui:define name="corpo">

		<div id="conteudo">

			<h:form id="form">
			
<!-- 			Falta o método para mostrar somente os documentos com status enviado -->

				<h2>
					<h:outputText value="EDITAR DOCUMENTO"/>
				</h2>

				<p:messages id="msg" />
					
				<p:fieldset legend="Pesquisar" style="background-image: url(resources/imagens/72.jpg);">
				
				<h:outputLink value="javascript:void(0)" onclick="dlgDoc.show();">
					<h:outputLabel value="Pesquisar Documento: " />
				</h:outputLink>
				<h:outputLink value="javascript:void(0)" onclick="dlgDoc.show();">
				<h:graphicImage value="resources/imagens/lupa.jpg"  onclick="dlgDoc.show();"
					style="width: 40px;"/>
				<h:outputText id="doc" value="#{documentoBean.documento.numero}" rendered="#{empty documentoBean.documento.numero}" />
				</h:outputLink>

				</p:fieldset>
				
				<h:panelGrid columns="3">
				<p:fieldset style="background-image: url(resources/imagens/72.jpg);" >
				
				<h:outputLabel value="Número: " for="numero" style="color: #1E90FF; font-weight:bold;" />
				<p:inputText id="numero" value="#{documentoBean.documento.numero}" /><br />
				
				<h:outputLabel value="Tipo de Documento: " for="tipo" style="color: #1E90FF; font-weight:bold;" />
				<p:inputText id="tipo" value="#{documentoBean.documento.tipo.nome}"/><br />
				
				<h:outputLabel value="Assunto: " for="assunto" style="color: #1E90FF; font-weight:bold;" />
				<p:inputText id="assunto" value="#{documentoBean.documento.assunto}"/><br />
				
				<h:outputLabel value="Descrição: " for="descricao" style="color: #1E90FF; font-weight:bold;" />
				<p:inputTextarea id="descricao" value="#{documentoBean.documento.descricao}"/><br />
				
				<h:outputLabel value="Data de Emissão: " style="color: #1E90FF; font-weight:bold;" />
				<p:calendar value="#{documentoBean.documento.data.time}">
					<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo" />
				</p:calendar><br />
				
				<p:commandButton id="grava" value="ALTERAR" action="#{documentoBean.grava}" ajax="false" image="ui-icon-pencil" update="msg"
					rendered="#{not empty documentoBean.documento.id}">
					<f:ajax render="@all" />
				</p:commandButton>		
				
				<p:commandButton id="cancel" value="CANCELAR" action="formAlterDocumento.xhtml"
						rendered="#{not empty documentoBean.documento.id}" ajax="false"  image="ui-icon-close" update="msg">
						<f:ajax render="@all" />
					</p:commandButton>
					
				<br />
				
				</p:fieldset>
				</h:panelGrid>
				<h:outputText value="Só é possível editar os documentos que estão com status 'ENVIADO' " style="color: blue;" />
			</h:form>	
			
			<p:dialog header="Documentos Cadastrados" widgetVar="dlgDoc" model="true" width="500" showEffect="hide">
					<h:form id="form1">

						<p:outputPanel id="docs">
							<p:dataTable value="#{documentoBean.documentos}" var="documento" paginator="true"
								rows="10" emptyMessage="Não Encontrado">

								<p:column filterBy="#{documento.numero}" filterMatchMode="contains"
									headerText="Numero">
									<h:commandLink value="#{documento.numero}" onclick="dlgDoc.hide()"
										id="empenho">
										<f:setPropertyActionListener
											target="#{documentoBean.documento}" value="#{documento}" />
									</h:commandLink>
								</p:column>
								
								<p:column headerText="Tipo">
									<h:outputText value="#{documento.tipo.nome}" />
								</p:column>
									
							</p:dataTable>
						</p:outputPanel>

					</h:form>
				</p:dialog>
							
		</div>


	</ui:define>
</ui:composition>
</html>